﻿using MovieAPI.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Cors;
using System.Web.Mvc;

namespace MovieAPI.Controllers
{
    [EnableCors(origins: "*", headers: "*", methods: "*"), RequireHttpsAttribute]
    public class AdminController : ApiController
    {
        public IHttpActionResult Login(dynamic Admin)
        {
            using (filmEntities db = new filmEntities())
            {
                string LoginName = Admin.Admin.LoginName;
                string LoginPwd = Admin.Admin.LoginPwd;
                var User = db.Admin.Where(A => A.AdminAccount == LoginName && A.AdminPwd == LoginPwd).FirstOrDefault();
                if (User != null)
                {
                    return Ok(1);
                }
                return Ok(0);
            }

        }
    }
}
